# -*- coding:UTF-8 -*-
'''
开发环境：PyCharm
创建日期：2025/8/20 17:22
作   者：新启典学苑-樱桃
描   述：pytest+数据驱动+requests 对注册、充值接口进行测试
       用字典存储测试数据
'''
import pytest
import requests


@pytest.fixture(params=[
    {"casename": "密码长度为5，注册失败",
     "data": {"mobilephone": "18012345678", "pwd": "12345", "regname": "12312"},
     "epxect": {"msg": "密码长度必须为6~18", "status": 0, "code": "20108"}},
    
   {"casename": "密码长度为19，注册失败",
     "data": {"mobilephone": "18012345678", "pwd": "1234567890123456789", "regname": "12312"},
     "epxect": {"msg": "密码长度必须为6~18", "status": 0, "code": "20108"}},
])  #yaml 文件
def zhuce_data(request):
    return request.param


def test_zhuce(zhuce_data):
    url = "http://192.168.1.29:8088/futureloan/mvc/api/member/register"
    print(f"测试注册功能，用例标题为：{zhuce_data['casename']}")
    r = requests.post(url, data=zhuce_data['data'])
    print(r.text)
    assert r.json()['msg'] == zhuce_data['epxect']['msg']
    assert r.json()['status'] == zhuce_data['epxect']['status']
    assert r.json()['code'] == zhuce_data['epxect']['code']